package cn.owng.server.platform.model.http.response;

import cn.owng.server.platform.model.vo.VO;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * 微信公众号请关注: 开源螺丝钉
 * <br>
 * 码云请关注: <a href="https://gitee.com/xiyoufang">https://gitee.com/xiyoufang</a>
 * <br>
 * 哔哩哔哩请关注: <a href="https://space.bilibili.com/438927834">https://space.bilibili.com/438927834</a>
 *
 * @author xiyoufang
 */
@Setter
@Getter
@Accessors(chain = true)
public class ResponseBodyEntity<T extends VO> {
    /**
     * 编码
     */
    private String code;
    /**
     * 信息
     */
    private String message;
    /**
     * 有效数据
     */
    private T data;

    public static <T extends VO> ResponseBodyEntity<T> create(ResponseCode code, T data, String message) {
        return new ResponseBodyEntity<T>()
                .setCode(code.name())
                .setMessage(message)
                .setData(data);
    }
}
